<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>
    <script>
        let cbs = [];
        let pendings = false;
        function flushCallbacks(){
            cbs.forEach(fn=>fn());
            pendings = false;
        }
        function nextTick(fn){
            cbs.push(fn);
            if(!pendings){
                pendings = true
                Promise.resolve().then(flushCallbacks)
            }
        }
        function render(){
            console.log('渲染')
        }
        nextTick(render);
        nextTick(render);
        nextTick(render);
        console.log('更状态')
        console.log('更状态')
        console.log('更状态')

    </script>
</body>
</html>